﻿using System;
using Pfz.AnimationManagement.Abstract;

namespace Pfz.AnimationManagement.Animations.Conditions
{
	public sealed class WaitCondition:
		IAnimation
	{
		public void Dispose()
		{
			Condition = null;
		}

		public Func<bool> Condition { get; set; }

		public bool IsUseless
		{
			get
			{
				return Condition == null;
			}
		}

		public void Reset()
		{
		}

		public bool Update(TimeSpan elapsed)
		{
			var condition = Condition;

			if (condition == null)
				return false;

			return !condition();
		}
	}
}
